import {
      WebSocketGateway,
      WebSocketServer,
      SubscribeMessage,
      MessageBody,
      OnGatewayConnection,
      OnGatewayDisconnect,
} from '@nestjs/websockets';

@WebSocketGateway()
export class WebsocketsGateway
      implements OnGatewayConnection, OnGatewayDisconnect {
      handleDisconnect(client: any) {
            console.log('mmmmmllllllll', client);
      }
      handleConnection(client: any, ...args: any[]) {
            console.log('mmmmm', client);
      }

      @SubscribeMessage('message')
      handleMessage(@MessageBody() data: string): string {
            console.log('Received message from client:', data);
            // 会接收到web的send方法里面的data数据
            return 'Hello from server! data:' + data;
      }
}
